import { View } from "../../../mvc/core/View";
import { LayerManager } from "../../manager/LayerManager";
import { ObjCreate } from "../common/ObjCreate";
import { ResFileConst } from "../../resource/ResFileConst";
import { SecTimerView } from "../common/SecTimerView";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { GTextFormat } from "../../../common/GTextFormat";
import { SCrossBossWaitingRoomOpen } from "../../../../Message/Public/SCrossBossWaitingRoomOpen";
import { ClockManager } from "../../manager/ClockManager";
import { HighlightManager } from "../../manager/HighlightManager";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
type int = number;
//class CrossBossHintButton
    
    export  class CrossBossHintButton extends View
    {
        constructor(arg1: int=0)
        {
            super();
            this._lv = arg1;
            this.layer = LayerManager.rightTopUILayer;
            this.initUI();
            return;
        }

        protected initUI(): void
        {
            if (this._lv != 70) 
            {
                if (this._lv != 90) 
                {
                    this._button = ObjCreate.createGLoadedButton(ResFileConst.CrossBossIcon, 0, 0, 60, 50, this);
                }
                else 
                {
                    this._button = ObjCreate.createGLoadedButton(ResFileConst.CrossBossIcon90, 0, 0, 60, 50, this);
                }
            }
            else 
            {
                this._button = ObjCreate.createGLoadedButton(ResFileConst.CrossBossIcon70, 0, 0, 60, 50, this);
            }
            this._secTime = new SecTimerView();
            this._secTime.y = 50;
            this._secTime.x = -10;
            this._secTime.width = 80;
            this._secTime.height = 20;
            this._secTime.filters = [FilterConst.glowFilter];
            this._secTime.setParse("<font color=\'0xFFFFFF\'>hh: mm: ss</font>");
            this._secTime.defaultTextFormat = new GTextFormat(null, 12, 16777215, null, null, null, null, null, flash.text.TextFormatAlign.CENTER);
            this._secTime.timeOutHandler = this.onSecTimeOutHandler;
            this.addChild(this._secTime);
            return;
        }

        /* internal  */onSecTimeOutHandler(): void
        {
            this.hide();
            return;
        }

        public updateTime(arg1: SCrossBossWaitingRoomOpen): void
        {
            this._openInfo = arg1;
            var loc1=new Date();
            loc1.setTime(arg1.closeDt.time - 600000);
            if (loc1.time > ClockManager.instance.nowDate.time) 
            {
                ClockManager.instance.addDateCall(loc1, this.onStartHintButton);
            }
            else 
            {
                this.onStartHintButton();
            }
            return;
        }

        /* internal  */onStartHintButton(): void
        {
            HighlightManager.instance.glowEffectButton(this._button, true);
            var loc1=(this._openInfo.closeDt.time - ClockManager.instance.nowDate.time) / 1000;
            this._secTime.setLeftTime(loc1);
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            this._secTime.stop();
            this._secTime.htmlText = "";
            HighlightManager.instance.glowEffectButton(this._button, false);
            return;
        }

        /* internal */ /* var */_button: GLoadedButton;

        /* internal */ /* var */_secTime: SecTimerView;

        /* internal */ /* var */_lv: int;

        /* internal */ /* var */_openInfo: SCrossBossWaitingRoomOpen;
    }
